package com.googlecode.volkien;

import android.content.Context;
import android.media.AudioManager;

public class VolumeController {
	
	Context mContext;
	boolean mEnabled = false;
	
	VolumeController(Context context) {
		mContext = context;
	}
	
	private AudioManager getAudioManager() {
		return (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
	}
	
	private int getStreamVolume(int stream) {
		return getAudioManager().getStreamVolume(stream);
	}
	
	private void setStreamVolume(int stream, int volume) {
		getAudioManager().setStreamVolume(stream, volume, AudioManager.FLAG_REMOVE_SOUND_AND_VIBRATE);
	}
	
	private int getStreamMaxVolume(int stream) {
		return getAudioManager().getStreamMaxVolume(stream);
	}
	
	public int getRingerMaxVolume() {
		return getStreamMaxVolume(AudioManager.STREAM_RING);
	}
	
	public int getRingerVolume() {
		return getStreamVolume(AudioManager.STREAM_RING);
	}
	
	public void setRingerVolume(int volume) {
		setStreamVolume(AudioManager.STREAM_RING, volume);
	}
	
	public boolean getEnabled() {
		return mEnabled;
	}
	
	public void setEnabled(boolean enabled) {
		mEnabled = enabled;
	}
}
